<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
require_once("lib/my_library.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtauthregistration.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Reminder_personnel extends Page
{
       public $JTJavaScript1 = null;
       public $JTSiteTheme1 = null;
       public $JTRemindPersonnel = null;
       public $hiddenPersonnel = null;
       function JTRemindPersonnelShow($sender, $params)
       {
        $query_emp = "select * from emp_license_tbl where emp_id='".$this->hiddenPersonnel->getValue()."'";
        $result_emp = mysql_query($query_emp)or die(mysql_error());
        //$row_emp = mysql_fetch_array($result_emp);
        $my_lib = new my_library();
        $rec_ctr = 0;

          while($row_check = mysql_fetch_array($result_emp))
          {

            $due_date = $row_check['license_renew_date'];
            $remind_me = $row_check['days'];
            $curr_date = date("Y-m-d");

            $emp_id = $row_check['emp_id'];

            $tools = "<img onclick=pop_close('".$_SESSION['company_id']."','".$emp_id."'); src='image/complete.png' title='Complete Reminder' style='cursor:pointer'>";

            if($due_date!=null || $due_date!='')
            $days_diff = $my_lib->daysDifference($due_date, $curr_date);

            if($days_diff<=$remind_me)
            {
               //if($days_diff<=14 && $days_diff>7)
               //$color = "Orange";
               if($days_diff<=$remind_me)
               $color = "red";

               $arr[] = array(
               'License Renewal due by' => "<p style='color:".$color."'>".$row_check['license_renew_date']."</p>",
               '' => $tools
               );
               //die(var_dump($arr));
               $rec_ctr++;
            }
          }


            if($rec_ctr==0 || $arr==null)
            $arr = array();
            $this->JTRemindPersonnel->setCellData($arr);


       }

       function Reminder_personnelCreate($sender, $params)
       {
       $emp = $_GET['emp'];
       $this->hiddenPersonnel->setValue($emp);
       }

}

global $application;

global $Reminder_personnel;

//Creates the form
$Reminder_personnel=new Reminder_personnel($application);

//Read from resource file
$Reminder_personnel->loadResource(__FILE__);

//Shows the form
$Reminder_personnel->show();

?>